package com.niit.dao.impl;

import java.util.List;

import com.niit.bean.QuesReply;
import com.niit.dao.QuesReplyDao;
import com.niit.utils.DbUtil;

public class QuesReplyDaoImpl implements QuesReplyDao {

	private DbUtil util =new DbUtil();
	@Override
	public int add(QuesReply t) {
		String sql="insert into tb_ques_reply (quesid,REPLIER,content) values(?,?,?)";
		int a=util.update(sql,t.getQuesId(), t.getReplier(),t.getContent());
		return a;
	}

	@Override
	public int delete(QuesReply t) {
		String sql="delete from tb_ques_reply where id=? ";
		int a=util.update(sql, t.getId());
		return a;
	}

	@Override
	public int update(QuesReply t) {
		return 0;
	}

	@Override
	public List<QuesReply> findAll(int start, int end) {
		String sql="select * from(select rownum r,tb_ques_reply.* from tb_ques_reply) a where a.r>? and a.r<=?";
		List<QuesReply> list =util.select(sql, QuesReply.class, start,end);
		return list;
	}

	@Override
	public int findTotal() {
		String sql = "select count(*) from tb_ques_reply  ";
		int count = util.selectCount(sql);
		return count;
	}

	@Override
	public List<QuesReply> findByQuesId(String quesId) {
		String sql = "select * from tb_ques_reply where quesid=?";
		List<QuesReply> list = util.select(sql, QuesReply.class, quesId);
		return list;
	}

}
